package ezCall;

import java.util.Enumeration;
import java.util.Vector;

import javax.microedition.pim.Contact;
import javax.microedition.pim.ContactList;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMException;
import javax.microedition.pim.PIMItem;
import javax.microedition.pim.PIMList;

import net.rim.blackberry.api.pdap.BlackBerryContact;
import net.rim.blackberry.api.pdap.BlackBerryContactList;
import net.rim.blackberry.api.pdap.BlackBerryPIM;
import net.rim.blackberry.api.pdap.BlackBerryPIMList;
import net.rim.blackberry.api.pdap.PIMListListener;
import net.rim.device.api.system.Application;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.util.CharacterUtilities;


public class Contact_DB  extends Thread 
{
    private BlackBerryContactList _Contact_List;
    private BlackBerryContact     _Contact_Item;
    private Vector      _Contact_Vector;	
    private Vector      _Searched_Contact_Vector;
    
    private String[]    _NameArray; 
    private String[]    _CompanyArray;

	private int[]       _NameFoundIndexArray;
	private int[]       _CompanyFoundIndexArray;
	private int[]       _PhoneNumberFoundIndexArray;
	
	private int[]       _TogleNameFoundIndexArray;
	private int[]       _TogleCompanyFoundIndexArray;
	
	private int         _NameFoundIndex;
	private int         _CompanyFoundIndex;	
	private int         _TogleNameFoundIndex;
	private int         _TogleCompanyFoundIndex;
	
	private int         _DB_Size;
	
    private String_Cho  _String_Cho;
    private boolean     _ContactOpened;

    private boolean     _Contact_Updated;
    
    private Gauge_PopupScreen _Gauge_Popup;

    private Contact_Listener  _Contact_Listener;
    
    private ezCall_Screen  _ezCall_Screen;
    private 
    int SearchIndex;
    
    private Option_Model _Option_Model;
    
    public Contact_DB()
    {
    	_Contact_Vector = new Vector();
  
    	_ContactOpened = false;
    	
    	_NameFoundIndex    = 0;
    	_CompanyFoundIndex = 0;
    	_TogleNameFoundIndex = 0;
    	_TogleCompanyFoundIndex = 0;
    	
    	_Gauge_Popup = new Gauge_PopupScreen( "Loading DB..", 0, 100 );
    	
    	_Contact_Updated = false;
    	
    	_Contact_Listener = new Contact_Listener(this);
    	
    }
    
    
    public void Set_Screen( ezCall_Screen _Screen_Arg )
    {
    	_ezCall_Screen = _Screen_Arg;
    }
    
	public void Set_OptionModel( Option_Model _Option_Model_Arg )
	{
		_Option_Model = _Option_Model_Arg;
	}
    
    
    
    // 주소록 데이터 바뀌었을떄 실행되는 함수
    //
	public void itemAdded(PIMItem item) 
	{
		FindField_Text _FindField_Text = new FindField_Text();
		
		_Contact_Vector.addElement( item );
		_Searched_Contact_Vector = _Contact_Vector;
		
		// ezCall DB 업데이트 
		Reload_ContactDB();

		// 리스트 업데이트 
		_FindField_Text.Set_Text("");
		Search( _FindField_Text );
		
		_Contact_Updated = true;
		
	}

	public void itemRemoved(PIMItem item) 
	{
		FindField_Text _FindField_Text = new FindField_Text();
		
		_Contact_Vector.removeElement( item );
		_Searched_Contact_Vector = _Contact_Vector;
			
		// ezCall DB 업데이트 
		Reload_ContactDB();

		// 리스트 업데이트 
		_FindField_Text.Set_Text("");
		Search( _FindField_Text );	
		
		_Contact_Updated = true;
	}

	public void itemUpdated(PIMItem oldItem, PIMItem newItem) 
	{
		FindField_Text _FindField_Text = new FindField_Text();
		
		String old_UID = oldItem.getString( BlackBerryContact.UID, 0 );
		String c_UID;
		
		int Size = _Contact_Vector.size();
		
		
		for( int i=0; i<Size; i++ )
		{
			c_UID = ((BlackBerryContact)_Contact_Vector.elementAt(i)).getString( BlackBerryContact.UID, 0 );

			if( c_UID.indexOf( old_UID ) == 0 )
			{
				_Contact_Vector.setElementAt(newItem, i);
				
				_Searched_Contact_Vector = _Contact_Vector;
			}
		}
		
		c_UID = null;
		old_UID = null;
		
		// ezCall DB 업데이트 
		Reload_ContactDB();

		// 리스트 업데이트 
		_FindField_Text.Set_Text("");
		Search( _FindField_Text );	
			
		_Contact_Updated = true;			
			
		
		_FindField_Text = null;
	}		
		
	
	
    public boolean Get_ContactUpdated()
    {
    	return _Contact_Updated;
    }
    
    public void Clear_ContactUpdated()
    {
    	_Contact_Updated = false;
    }    
    
    public boolean isContactLoaded() 
    {
    	return _ContactOpened;
    }
    
    
    public void Add_ContactListener()
    {
    	
    	  }
    
    
    public void run() 
    {
    	
    	UiApplication.getUiApplication().invokeLater(new Runnable()     	
    	{
            public void run() 
            {
            	
            	_Gauge_Popup.Push_Screen();
            }
    	} );
    	

    	
    	_ContactOpened = Open_ContactDB();

    	
    	if( _ContactOpened == true )
    	{
    		Reload_ContactDB();
    	}    	
    	


    	//if (_Gauge_Popup.isDisplayed()) 
    	//{
            UiApplication.getUiApplication().invokeLater(new Runnable() 
            {
                public void run() 
                {
                	_Gauge_Popup.Pop_Screen();
                	
                	
                }
            });
    	//}    	
            
        synchronized(Application.getEventLock())
        {
        	_ezCall_Screen.Show_AllPhoneList();
        }
            
    	
    }
 
    public boolean Open_ContactDB() 
    {
	    try
	    {            
	        _Contact_List = (BlackBerryContactList)BlackBerryPIM.getInstance().openPIMList(BlackBerryPIM.CONTACT_LIST, BlackBerryPIM.READ_ONLY);
	    	 
	        Enumeration Contact_ListEnum = _Contact_List.items();
	        

	        
	        //_Contact_Vector = enumToVector( Contact_ListEnum );            
	        
	        if( _Contact_Vector.size() > 0 )
	        {
	        	_Contact_Vector.removeAllElements();
	        }
	        
	        
	        
	        if (Contact_ListEnum != null)
	        {
	        
		        SearchIndex = 0;

		        while (Contact_ListEnum.hasMoreElements())
		        {
		        	
		        	synchronized(Application.getEventLock()) 
		        	{
		        		_Gauge_Popup.Set_Value(SearchIndex++);
		            }
		        	
		       		_Contact_Vector.addElement(Contact_ListEnum.nextElement());
		        }	        
	        }	        
	        _Searched_Contact_Vector = _Contact_Vector;

	        
	        // 주소록 업데이트시 리스너
	        ((BlackBerryPIMList) _Contact_List).addListener((PIMListListener)_Contact_Listener);
		      
	        
	        return true;            
	    }
	    catch (PIMException e)
	    {
	    	Dialog.alert( "PIM Open Error" );
	        return false;
	    }
    }
    
    
    public void Remove_Listener()
    {
        // 주소록 업데이트시 리스너
        ((BlackBerryPIMList) _Contact_List).removeListener((PIMListListener)_Contact_Listener);
    }
    public boolean Reload_ContactDB()
    {

    	int SearchMaxSize = _Searched_Contact_Vector.size();
    	
    	
    	if( _NameArray != null ) _NameArray = null;
     	if( _CompanyArray != null ) _CompanyArray = null;
     	if( _NameFoundIndexArray != null ) _NameFoundIndexArray = null;
     	if( _CompanyFoundIndexArray != null ) _CompanyFoundIndexArray = null;
     	if( _PhoneNumberFoundIndexArray != null ) _PhoneNumberFoundIndexArray = null;
        if( _TogleNameFoundIndexArray != null ) _TogleNameFoundIndexArray = null; 	
        if( _TogleCompanyFoundIndexArray != null ) _TogleCompanyFoundIndexArray = null;
    	
    	
    	
    	_NameArray    = new String[ SearchMaxSize ];
    	_CompanyArray = new String[ SearchMaxSize ];

    	_NameFoundIndexArray    = new int[ SearchMaxSize ];
    	_CompanyFoundIndexArray = new int[ SearchMaxSize ];
    	_PhoneNumberFoundIndexArray = new int[ SearchMaxSize ];
    	
    	_TogleNameFoundIndexArray = new int[ SearchMaxSize ];
    	_TogleCompanyFoundIndexArray = new int[ SearchMaxSize ];
    	
    	// ContactDB 벡터에서 문자열 배열로 저장(속도를 위해)
    	//
    	for( int SearchIndex=0; SearchIndex < SearchMaxSize; SearchIndex++ )
    	{
    		
    		Contact c = (BlackBerryContact)_Contact_Vector.elementAt( SearchIndex );
    		
            
    		String StrBuf;
    		StringBuffer StrOutBuf = new StringBuffer();    		
			
    		
    		if( c.countValues( Contact.NAME ) > 0 )
    		{
    			
    			String[] NameArray  = c.getStringArray(Contact.NAME, 0);
    			
	    		// 이름 문자열 저장
	    		//
	    		if(NameArray[Contact.NAME_FAMILY] != null)
					StrOutBuf.append( NameArray[Contact.NAME_FAMILY] );                 	
				
	    		if(NameArray[Contact.NAME_GIVEN] != null)
	    			StrOutBuf.append( NameArray[Contact.NAME_GIVEN] );
	 		
    			
	    		if( StrOutBuf.length() > 0 )
	    		{
		    		_NameArray[ SearchIndex ] = _String_Cho.Get_ChoSung( StrOutBuf.toString().toUpperCase() );    		
		    		_NameArray[ SearchIndex ] = Remove_SpaceFromString(_NameArray[ SearchIndex ] );
	    		}
	    		
    		}

    		
    		
    		if( c.countValues( Contact.ORG ) > 0 )
    		{
	    		String   CompanyStr = c.getString(Contact.ORG, 0);
	    		// 회사 문자열 저장
	    		//
	    		_CompanyArray[ SearchIndex ] = String_Cho.Get_ChoSung( CompanyStr.toUpperCase() );
	    		_CompanyArray[ SearchIndex ]= Remove_SpaceFromString(_CompanyArray[ SearchIndex ] );
    		}
	    	else
	    	{
	    		_CompanyArray[ SearchIndex ] = "";
	    	}
    	}
    	
    	
    	return true;
    }    
    
    

    public void ReloadDB() 
    {
    	UiApplication.getUiApplication().invokeLater(new Runnable() 
    	{
            public void run() 
            {
            	
            	_Gauge_Popup.Push_Screen();
            }
    	} );
    	

    	
    	_ContactOpened = Open_ContactDB();

    	
    	if( _ContactOpened == true )
    	{
    		Reload_ContactDB();
    	}    	
    	


    	//if (_Gauge_Popup.isDisplayed()) 
    	//{
            UiApplication.getUiApplication().invokeLater(new Runnable() 
            {
                public void run() 
                {
                	_Gauge_Popup.Pop_Screen();
                }
            });
    	//}   
    }
    
    
    
    public int Get_MaxSize() 
    {
    	return (_NameFoundIndex+_CompanyFoundIndex+_TogleNameFoundIndex+_TogleCompanyFoundIndex);
    }

    public Object Get_ItemObjectFromIndex( int ObjIndex )
    {
    	
    	if( ObjIndex > _Searched_Contact_Vector.size() ) return null;    	
    	
    	if( ObjIndex >= (_NameFoundIndex+_CompanyFoundIndex)) 
    		return Get_TogleItemObjectFromIndex( ObjIndex-(_NameFoundIndex+_CompanyFoundIndex) );
    	
    	
    	if( _Option_Model.Get_Find_SubMode() == Option_Model.FIND_SUBMODE_NAME_COMPANY )
		{
    		if( ObjIndex < _NameFoundIndex )
    			return _Searched_Contact_Vector.elementAt(  _NameFoundIndexArray[ObjIndex] );
    		else
    			return _Searched_Contact_Vector.elementAt(  _NameFoundIndexArray[ObjIndex-_NameFoundIndex] );
		}

    	if( _Option_Model.Get_Find_SubMode() == Option_Model.FIND_SUBMODE_NAME_FIRST )
		{
    		if( ObjIndex < _NameFoundIndex )
    		{
    			return _Searched_Contact_Vector.elementAt(  _NameFoundIndexArray[ObjIndex] );
    		}
    		else
    		{
    			return _Searched_Contact_Vector.elementAt(  _CompanyFoundIndexArray[ObjIndex-_NameFoundIndex] );
    		}
		}
    	
    	if( _Option_Model.Get_Find_SubMode() == Option_Model.FIND_SUBMODE_COMPANY_FIRST )
		{
    		if( ObjIndex < _CompanyFoundIndex )
    		{
    			return _Searched_Contact_Vector.elementAt(  _CompanyFoundIndexArray[ObjIndex] );
    		}
    		else
    		{
    			return _Searched_Contact_Vector.elementAt(  _NameFoundIndexArray[ObjIndex-_CompanyFoundIndex] );
    		}
		}
    	
    	
    	return _Searched_Contact_Vector.elementAt(  _NameFoundIndexArray[ObjIndex] );
    }
    
    
    
    
    
    public Object Get_TogleItemObjectFromIndex( int ObjIndex )
    {
    	
    	if( _Option_Model.Get_Find_SubMode() == Option_Model.FIND_SUBMODE_NAME_COMPANY )
		{
    		if( ObjIndex < _TogleNameFoundIndex )
    			return _Searched_Contact_Vector.elementAt(  _TogleNameFoundIndexArray[ObjIndex] );
    		else
    			return _Searched_Contact_Vector.elementAt(  _TogleNameFoundIndexArray[ObjIndex-_TogleNameFoundIndex] );
		}

    	if( _Option_Model.Get_Find_SubMode() == Option_Model.FIND_SUBMODE_NAME_FIRST )
		{
    		if( ObjIndex < _TogleNameFoundIndex )
    		{
    			return _Searched_Contact_Vector.elementAt(  _TogleNameFoundIndexArray[ObjIndex] );
    		}
    		else
    		{
    			return _Searched_Contact_Vector.elementAt(  _TogleCompanyFoundIndexArray[ObjIndex-_TogleNameFoundIndex] );
    		}
		}
    	
    	if( _Option_Model.Get_Find_SubMode() == Option_Model.FIND_SUBMODE_COMPANY_FIRST )
		{
    		if( ObjIndex < _TogleCompanyFoundIndex )
    		{
    			return _Searched_Contact_Vector.elementAt(  _TogleCompanyFoundIndexArray[ObjIndex] );
    		}
    		else
    		{
    			return _Searched_Contact_Vector.elementAt(  _TogleNameFoundIndexArray[ObjIndex-_TogleCompanyFoundIndex] );
    		}
		}
    	
    	
    	return null;
    }
    
    
    
    
    
    private Vector enumToVector(Enumeration enumeration)
    {
        Vector v = new Vector();
        
        
        int SearchIndex;
        
        if (enumeration == null)
            return v;
        
        SearchIndex = 0;

        while (enumeration.hasMoreElements())
        {
       		//화면에 진행 상황 표시
       		_Gauge_Popup.Set_SafeValue(SearchIndex++);

            v.addElement(enumeration.nextElement());
        }
        return v;
    }       
    
    
    public boolean Search( FindField_Text SearchNameText )
    {
    	int SearchIndex;
    	int SearchMaxSize;
    	boolean ret = false;
    	BlackBerryContact Contact_Item;
    	int MatchedPhoneNumberIndex;
    	int MatchedNoteIndex;
    	int MatchedCateIndex;

    	String SearchName;
    	String SearchTogleName;
    	
    	int    _Find_Mode;
    	
    	boolean FoundName;
    	boolean TogleFoundName;
    	
    	
    	
    	// 찾는 문자열이 없으면
    	if( SearchNameText.Get_StrSize() == 0 )
    	{
    		CopyAllIndexFromVector();
    		return false;
    	}
    	
    	// 검색 단축어만 있고 문자열이 없을때
    	if( SearchNameText.isValidText() == false )
    	{    		
    		return false;
    	}
    	
    	
    	_Find_Mode      = SearchNameText.Get_FindMode();
    	SearchName      = SearchNameText.Get_Text().toUpperCase();
    	SearchTogleName = String_Cho.Get_ToggledStr(SearchName).toUpperCase(); 
    	
    	SearchMaxSize = _Contact_Vector.size();

    	
    	_NameFoundIndex    = 0;
    	_CompanyFoundIndex = 0;
    	_TogleNameFoundIndex = 0;
    	_TogleCompanyFoundIndex = 0;
    	
    	// ContactDB 에서 찾고자 하는 문자열로 검색
    	//
    	for( SearchIndex=0; SearchIndex < SearchMaxSize; SearchIndex++ )
    	{
    		FoundName = false;
    		TogleFoundName = false;
    		
    		switch( _Find_Mode )
    		{
    		case FindField_Text.FIND_MODE_NAME_COMPANY:
    			
    		
    			if( _NameArray[ SearchIndex ] != null ) 
    			{   
    	   			if( _NameArray[ SearchIndex ].indexOf( SearchTogleName) >= 0 )
	             	{	    				
	    				_TogleNameFoundIndexArray[_TogleNameFoundIndex] = SearchIndex;
	    				_TogleNameFoundIndex++;
	    				
	    				TogleFoundName = true;
	             	}  
    	   			
	        		//-- 이름 검색
	        		//
	    			if( _NameArray[ SearchIndex ].indexOf( SearchName) >= 0 )
	             	{	    				
	    				_NameFoundIndexArray[_NameFoundIndex] = SearchIndex;
	    				_NameFoundIndex++;
	    				
	    				FoundName = true;
	             	}   
    			}
    			
    			if( _CompanyArray[ SearchIndex ] != null ) 
    			{
    				
    	    		//-- 회사 검색
    	    		//
    				if( _CompanyArray[ SearchIndex ].indexOf( SearchTogleName) >= 0 && TogleFoundName == false )
    	         	{
    					if( _Option_Model.Get_Find_SubMode() == Option_Model.FIND_SUBMODE_NAME_COMPANY )
    					{
    	    				_TogleNameFoundIndexArray[_TogleNameFoundIndex] = SearchIndex;
    	    				_TogleNameFoundIndex++;
    					}
    					else
    					{
    						_TogleCompanyFoundIndexArray[_TogleCompanyFoundIndex] = SearchIndex;
    						_TogleCompanyFoundIndex++;
    					}
    	         	}   
    				
    					
    	    		//-- 회사 검색
    	    		//
    				if( _CompanyArray[ SearchIndex ].indexOf( SearchName) >= 0 && FoundName == false )
    	         	{
    					if( _Option_Model.Get_Find_SubMode() == Option_Model.FIND_SUBMODE_NAME_COMPANY )
    					{
    	    				_NameFoundIndexArray[_NameFoundIndex] = SearchIndex;
    	    				_NameFoundIndex++;
    					}
    					else
    					{
    						_CompanyFoundIndexArray[_CompanyFoundIndex] = SearchIndex;
    						_CompanyFoundIndex++;
    					}
    	         	}   
    			}    			
    			break;

    			
    		case FindField_Text.FIND_MODE_CHAR_NAME_FIRST:
    			
    			if( _NameArray[ SearchIndex ] == null ) break;
    			
    			
    			if( _NameArray[ SearchIndex ].indexOf( SearchTogleName) == 0 )
             	{
    				_TogleNameFoundIndexArray[_TogleNameFoundIndex] = SearchIndex;
    				_TogleNameFoundIndex++;
             	} 
    			
        		//-- 이름 검색
        		//
    			if( _NameArray[ SearchIndex ].indexOf( SearchName) == 0 )
             	{
    				_NameFoundIndexArray[_NameFoundIndex] = SearchIndex;
    				_NameFoundIndex++;
             	}     			
    			break;  
    			
    		
    		case FindField_Text.FIND_MODE_CHAR_COMPANY_FIRST:
    			
    			if( _CompanyArray[ SearchIndex ] == null ) break;
    			
    			if( _CompanyArray[ SearchIndex ].indexOf( SearchTogleName ) == 0 )
             	{
    				_TogleCompanyFoundIndexArray[_TogleCompanyFoundIndex] = SearchIndex;
    				_TogleCompanyFoundIndex++;
             	}  
    			
    			
        		//-- 회사 검색
        		//
    			if( _CompanyArray[ SearchIndex ].indexOf( SearchName) == 0 )
             	{
    				_CompanyFoundIndexArray[_CompanyFoundIndex] = SearchIndex;
    				_CompanyFoundIndex++;
             	}     			
    			break;     		
    			
    			
    		case FindField_Text.FIND_MODE_PHONE_NUMBER:
    			Contact_Item = (BlackBerryContact)_Searched_Contact_Vector.elementAt( SearchIndex );
    				
    			MatchedPhoneNumberIndex = Get_MatchedPhoneNumberIndex( Contact_Item, SearchName ); 
    			if(  MatchedPhoneNumberIndex >= 0 )
    			{
					_NameFoundIndexArray[_NameFoundIndex] = SearchIndex;
					_PhoneNumberFoundIndexArray[_NameFoundIndex] = MatchedPhoneNumberIndex;
					_NameFoundIndex++;
    			}
    			
    			break;
    			
    		case FindField_Text.FIND_MODE_NOTE:
    			Contact_Item = (BlackBerryContact)_Searched_Contact_Vector.elementAt( SearchIndex );
				
    			MatchedNoteIndex = Get_MatchedNoteIndex( Contact_Item, SearchName ); 
    			if(  MatchedNoteIndex >= 0 )
    			{
					_NameFoundIndexArray[_NameFoundIndex] = SearchIndex;
					_NameFoundIndex++;
    			}		
    			break;
    	    
    		case FindField_Text.FIND_MODE_CATE:
    			Contact_Item = (BlackBerryContact)_Searched_Contact_Vector.elementAt( SearchIndex );
				
    			MatchedCateIndex = Get_MatchedCateIndex( Contact_Item, SearchName ); 
    			if(  MatchedCateIndex >= 0 )
    			{
					_NameFoundIndexArray[_NameFoundIndex] = SearchIndex;
					_NameFoundIndex++;
    			}	    			
    			
    			break;    	 

    		}
		
    	}
    	
    	
    	if( _NameFoundIndex > 0 )
    	{
    		ret = true;
    	}
    	
    	return ret;
    }
    
    
	public String Remove_SpecialCharFromPhoneNumbner( String PhoneNumber )
	{
		String RetStr = new String();
		
		for( int i=0; i < PhoneNumber.length(); i++  )
		{
			if( CharacterUtilities.isDigit( PhoneNumber.charAt(i) ) )
			{
				RetStr += PhoneNumber.charAt(i);
			}
		}
		
		return RetStr;
	}
	
    
	public int Get_MatchedPhoneNumberIndex( Contact c, String SearchName )
	{
		String Str= new String();
		
		int ContactFieldCount = c.countValues( Contact.TEL);
		
		
		if( ContactFieldCount > 0 )
		{
			for( int i=0; i<ContactFieldCount; i++ )
			{
				 Str =  Remove_SpecialCharFromPhoneNumbner( c.getString( Contact.TEL, i)); 
		
				 
				 if( Str.indexOf(SearchName) >= 0 )
				 {					 
					return i;
				 }
				 
			}
		}
		
		return -1;
	}

	
	public int Get_MatchedNoteIndex( BlackBerryContact c, String SearchName )
	{
		
		int ContactFieldCount = c.countValues( Contact.NOTE );
		
		if( ContactFieldCount > 0 )
		{
			for( int i=0; i<ContactFieldCount; i++ )
			{
				 if( String_Cho.Get_ChoSung(c.getString( Contact.NOTE, i).toUpperCase()).indexOf(SearchName) >= 0 )
				 {					 
					return i;
				 }
			}
		}		
		return -1;
	}	
	
	
	public int Get_MatchedCateIndex( BlackBerryContact c, String SearchName )
	{
		String[] CateArray;
		
		CateArray = c.getCategories();
		
		if( CateArray.length > 0 )
		{
			for( int i=0; i<CateArray.length; i++ )
			{
				if( String_Cho.Get_ChoSung( CateArray[i].toUpperCase()).indexOf(SearchName) >= 0 )
				{
					return i;
				}
			}
		}		
		return -1;
	}	
	
	
	
	public String Get_MatchedNoterStr( BlackBerryContact c )
	{		
		return c.getString( Contact.NOTE, 0);
	}

	
	public String Get_MatchedPhoneNumberStr( BlackBerryContact c, int Index )
	{		
		return c.getString( Contact.TEL, _PhoneNumberFoundIndexArray[Index]);
	}
	
	
	
	
	
    void CopyAllIndexFromVector()
    {
    	int SearchMaxSize = _Contact_Vector.size();
    	    	
    	
    	_NameFoundIndex    = 0;
    	_CompanyFoundIndex = 0;
    	
    	// ContactDB 에서 찾고자 하는 문자열로 검색
    	//
    	for(int SearchIndex=0; SearchIndex < SearchMaxSize; SearchIndex++ )
    	{
			_NameFoundIndexArray[_NameFoundIndex] = SearchIndex;
			_NameFoundIndex++;			
    	}
    }

    String Remove_SpaceFromString( String Str )
    {
		String RetStr = new String();
		
		for( int i=0; i < Str.length(); i++  )
		{
			// 공백 문자 제거
			if( CharacterUtilities.isSpaceChar( Str.charAt(i)) == false )
			{
				RetStr += Str.charAt(i);
			}
		}
		
		return RetStr;
	}
    

}
